package com.yzzrjy.controller.mainservlet.blog;

import com.yzzrjy.Service.BlogService;
import com.yzzrjy.bean.BlogCommentBean;
import com.yzzrjy.util.ResponseUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet(name = "GetBlogCommentServlet", value = "/getBlogComment")
public class GetBlogCommentServlet extends HttpServlet {
    private BlogService blogService = new BlogService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");
        String token = request.getParameter("token");
        String blogId = request.getParameter("blogId");
        if(uid == null || token == null || blogId == null){
            ResponseUtils.parameterError(response);
            return;
        }

        try {
            List<BlogCommentBean> list = blogService.getBlogComment(blogId);
            ResponseUtils.success(response, list);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
